package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.BaseCategory3;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BaseCategory3Mapper extends BaseMapper<BaseCategory3> {


    @Select("select bc3.id,\n" +
            "       bc3.name,\n" +
            "       bc3.category2_id,\n" +
            "       bc3.order_num,\n" +
            "       bc3.is_top,\n" +
            "       bc3.create_time\n" +
            "\n" +
            "from base_category3 bc3\n" +
            "         inner join base_category2 bc2 on bc3.category2_id = bc2.id and bc2.is_deleted = 0\n" +
            "         inner join base_category1 bc1 on bc2.category1_id = bc1.id and bc1.is_deleted = 0\n" +
            "where bc1.id = #{category1Id}\n" +
            "  and bc3.is_top = 1\n" +
            "  and bc3.is_deleted = 0\n" +
            "order by bc3.order_num\n" +
            "limit 7\n")
    List<BaseCategory3> findTopBaseCategory3(Long category1Id);
}
